package com.gjx.springboot.api.controller;

import com.gjx.springboot.domain.entity.Departments;
import com.gjx.springboot.app.service.DepartMentsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class DepartMentsController {
    @Autowired
    DepartMentsService departMentsService;
    @RequestMapping("/getalldepartments")
    @ResponseBody
    public List<Departments> getAll(){
        List<Departments> allDepartMents = departMentsService.getAllDepartMents();
        return allDepartMents;
    }

    @RequestMapping("/insertonedepartment")
    @ResponseBody
    public Boolean insertOneDepartMent(Departments departments){
        Boolean aBoolean = departMentsService.insertOneDepartMent(departments);
        return  aBoolean;
    }
    @RequestMapping("/updateonedepartment")
    @ResponseBody
    public Boolean updateOneDepartMent(Departments departments){
        Boolean aBoolean = departMentsService.updateOneDepartMent(departments);
        return aBoolean;
    }
    @RequestMapping("/deleteonedepartment")
    @ResponseBody
    public Boolean deleteOneDepartMent(Integer departmentId){
        Boolean aBoolean = departMentsService.deleteOneDepartMent(departmentId);
        return  aBoolean;
    }
}
